using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using buildingLib;
using buildingLib.daily;

namespace _dmis
{
    public partial class CarcerEdit : _dmis.WinPart
    {
        Owner m_owner;
        buildingLib.daily.CarCer m_carcer;
        public CarcerEdit(buildingLib.daily.CarCer carcer,Owner owner)
        {
            InitializeComponent();
            m_owner = owner;
            m_carcer = carcer;
            this.carCersBindingSource.DataSource = m_carcer;
        }

        #region WinPart Code

        protected internal override object GetIdValue()
        {
            return m_carcer;
        }

        public override string ToString()
        {
            return m_carcer.ID.ToString();
        }

        private void ResourceEdit_CurrentPrincipalChanged(object sender, EventArgs e)
        {
            ApplyAuthorizationRules();
        }
        #endregion

        private void ApplyAuthorizationRules()
        {
            
        }

        private void carCersBindingSource_CurrentItemChanged(object sender, EventArgs e)
        {
            this.tsb_save.Enabled = m_carcer.IsSavable;
        }

        private void tsb_close_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void tsb_save_Click(object sender, EventArgs e)
        {
            m_owner.Cars.Add(m_carcer);          
            this.Close();
        }
    }
}

